1. Field of the Invention
The present invention relates to a program control unit and a program control method to control execution of a program.
2. Description of the Background Art
For real-time applications, a smooth flow of instructions is imperative. When, for example, a filter algorithm is implemented with a processor of any kind, the overlapped scanning of the applied matrices provides the best results in terms of speed, if the vertical and horizontal scannings are executed without interruptions by a repetition of the individual loop instruction.
Therefore, a program control unit for controlling execution of a program generally allows a loop instruction to be executed so that a repeated processing can be simply performed.
In the case of a single loop, the syntax of a standard loop instruction is shown in FIG. 17, where "lc" represents a loop counter and "End" represents an address of the last instruction of the repeated loop block.
This syntax includes one severe restriction to the programmer: The loop instruction has to be exactly one line above the first line of the loop block (line 40 of FIG. 17), i.e., to be placed on line 39 of FIG. 17.
The standard nesting of two loops is shown in FIG. 18.
As can be seen from FIG. 18, a loop block Block1 positioned on lines 36 to 45 surrounds another loop block Block2 positioned on lines 40 to 42. The loop instruction (on line 39) of the inner loop block Block2 is repeated every time the surrounding block Block1 is executed.
Actually, the loop instructions on lines 35 and 39 have to be executed only one time for the transfer of the information (loop counter, start address and end address).
Nonetheless, the loop instruction of Block2 is repeated every time the loop block Block1 is executed, and accordingly, (lc1-1) cycles are executed inefficiently. This inefficient execution of the loop instruction has a profound ill effect on performance of a filter application and the like. A detailed discussion will follow.
The effects are best illustrated by an example of a filter application. If a matrix of pixel data is applied to a convolution mask of three-to-three elements (e.g. "Laplacian Edge Detection"), special care has to be taken at the start and end of each horizontal scanning line. For extrapolation of the border pixel, "virtual" zeros are inserted along the borders, as shown in FIG. 19.
The inner pixels of the frame are easily processed by using an indexed array for the addressing of the data stack. If the mask is shifted, the index is incremented. Thus, a repeated block, i.e., a loop processing, can be applied, for the horizontal scanning of the mask. For the borders of the mask, however, the blocks are irregular, due to the insertion of the zeros.
This entails a separate block (BlockA, BlockB and BlockC) at the start and end of each frame line to be processed in a program as shown in FIG. 20, for the mask processing of the pixels of FIG. 19. FIG. 20 shows a program for implementing a horizontal scanning, in which pixel data Pixel1 to Pixel6 are stored in indexed arrays a[0] to a[5]. In the program, a[i, 1] represents incrementing a variable i by 1 after fetching the value from the array a[i], and a[i, -1] represents decrementing a variable i by 1 after fetching the data value from the array a[i]. Further, wr[0] to wr[2] represent arrays storing the values of the first line of the mask, "load" represents a data load instruction and "mulacc" represents an operational instruction. The variable i has an initial value "1", not shown in FIG. 20.
If the standard loop instruction is applied, it has to be positioned between the block BlockA and a loop block BlockB (on line 39 of FIG. 20). The loop instruction on line 39 causes an irregularity, since not three but four steps including the loop instruction are required to process the border pixel before BlockB, which disables a real-time processing of the complete frame.
Furthermore, since an actual filtering processing requires a horizontal scanning as an inner loop and a vertical scanning as an outer loop, the loop instruction for the horizontal scanning has to be repeated every time the outer loop (vertical scanning) is executed, resulting in an increase of the overall processing time.
In the background art program control unit, the loop instruction as above causes a problem of inefficiency of a program and an increase of processing time in such an application processing as filtering processing.